﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using Entity;
using BusinessObject;

namespace GreenLife.Admin
{
    public partial class ChinhSuaKhachHang : System.Web.UI.Page
    {
        DataSet ds;
        Customer c;
        CustomerBO cBO = new CustomerBO();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                selectCustomerById();
            }
        }

        public void selectCustomerById()
        {
            c = new Customer();
            int id = Int32.Parse(Request.QueryString["id"]);
            c = cBO.selectCustomerById(id);

            txtID.Text = c.CustomerID.ToString();
            txtName.Text = c.CustomerName.ToString();
            txtPhone.Text = c.CustomerPhone.ToString();
            txtEmail.Text = c.CustomerEmail.ToString();
        }

        protected void btnUpdate_Click(object sender, EventArgs e)
        {
            c = new Customer();
            c.CustomerID = Int32.Parse(txtID.Text);
            c.CustomerName = txtName.Text;
            c.CustomerPhone = txtPhone.Text;
            c.CustomerEmail = txtEmail.Text;
            if (cBO.updateCustomer(c))
            {
                Response.Redirect("DanhSachKhachHang.aspx");
            }
        }
    }
}